package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import flc.ast.R;
import flc.ast.bean.MyDrawBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class MaterialAdapter extends StkProviderMultiAdapter<Integer> {

    public MaterialAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(35));
        addItemProvider(new MaterialProvider());
    }

    private class MaterialProvider extends BaseItemProvider<Integer> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_material;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, Integer bean) {
            baseViewHolder.setImageResource(R.id.ivMaterialItemImg, bean);
            List<Integer> list = new ArrayList<>();
            list.add(R.drawable.t1);
            list.add(R.drawable.t2);
            list.add(R.drawable.t3);
            list.add(R.drawable.t4);
            list.add(R.drawable.t5);
            list.add(R.drawable.t6);
            list.add(R.drawable.t7);
            list.add(R.drawable.t8);
            list.add(R.drawable.t9);
            list.add(R.drawable.t10);
            list.add(R.drawable.t11);
            list.add(R.drawable.t12);
            list.add(R.drawable.t13);
            list.add(R.drawable.t14);
            list.add(R.drawable.t15);
            list.add(R.drawable.t16);
            list.add(R.drawable.t17);
            list.add(R.drawable.t18);
            list.add(R.drawable.t19);
            list.add(R.drawable.t20);
            list.add(R.drawable.t21);
            list.add(R.drawable.t22);
            list.add(R.drawable.t23);
            list.add(R.drawable.t24);
            list.add(R.drawable.t25);
            list.add(R.drawable.t26);
            list.add(R.drawable.t27);
            list.add(R.drawable.t28);
            list.add(R.drawable.t29);
            list.add(R.drawable.t30);
            list.add(R.drawable.t31);
            list.add(R.drawable.t32);
            Random random = new Random();
            baseViewHolder.setImageResource(R.id.ivMaterialItemAvatar1, list.get(random.nextInt(list.size())));
            baseViewHolder.setImageResource(R.id.ivMaterialItemAvatar2, list.get(random.nextInt(list.size())));
            baseViewHolder.setImageResource(R.id.ivMaterialItemAvatar3, list.get(random.nextInt(list.size())));
            baseViewHolder.setImageResource(R.id.ivMaterialItemAvatar4, list.get(random.nextInt(list.size())));
            int num = random.nextInt(1000) + 1000;
            baseViewHolder.setText(R.id.tvMaterialItemNum, getContext().getString(R.string.like_num, num));
        }
    }
}
